﻿using System;
using System.Diagnostics;
using System.Windows.Forms;
using Business.Properties;

namespace Business.Forms
{
    public partial class FormConfigBusiness : DevExpress.XtraEditors.XtraForm
    {
        public FormConfigBusiness()
        {
            InitializeComponent();

            settingsBindingSource.DataSource = Settings.Default;
        }

        private void cmdCancelar_Click(object sender, System.EventArgs e)
        {
            var s = (Settings)settingsBindingSource.DataSource;
            s.Reload();
            Dispose();
        }

        private void cmdSalvar_Click(object sender, System.EventArgs e)
        {
            try
            {

                var s = (Settings)settingsBindingSource.DataSource;
                s.Save();
                var r = MessageBox.Show("A aplicação será reiniciada para que as alterações " +
                                       "tenham efeito.\n\n Deseja continuar?",
                    "Atenção", MessageBoxButtons.YesNo);
                if (r == DialogResult.Yes)
                {
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao salvar configurações: " + ex.Message);

            }

        }

        private void cmdCriarDB_Click(object sender, System.EventArgs e)
        {
            
        }

    }
}